import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getAreaDictList, getMineralDictList } from '@/api/dict'

export const dictStore = defineStore('dict', () =>{
  const areaList = ref([])
  const sensorTypeList = ref([])
  const alarmTypeList = ref([])

  const getAreaList = async () => {
    if (areaList.value.length > 0) return areaList.value
    const { data } = await getAreaDictList()
    areaList.value = data
    return data
  }

  const getSensorTypeList = async () => {
    if (sensorTypeList.value.length > 0) return sensorTypeList.value
    const { data } = await getMineralDictList()
    sensorTypeList.value = data
    return data
  }

  // const getAlarmTypeList = async () => {
  //   const { data } = await getAlarmTypeList()
  //   alarmTypeList.value = data
  // }

  return {
    areaList,
    sensorTypeList,
    alarmTypeList,
    getAreaList,
    getSensorTypeList
  }
}, {

})


